<%@ page contentType="text/html;charset=UTF-8" language="java"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()+ path + "/";
%>
<html>
	 <head>
        <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0" />
        <meta name="format-detection" content="telephone=no">
        <meta charset="UTF-8">
        <meta name="description" content="Violate Responsive Admin Template">
        <meta name="keywords" content="Super Admin, Admin, Template, Bootstrap">
        <script src="<%=path %>/assets2/js/jquery-1.11.1.min.js"></script>
   		<script src="<%=path %>/assets2/js/bootstrap.min.js"></script>
   		<script src="<%=basePath%>/assets2/js/highcharts/highcharts.js"></script>
		<script src="<%=basePath%>/assets2/js/highcharts/highcharts-3d.js"></script>
		<script src="<%=basePath%>/assets2/js/highcharts/modules/exporting.js"></script>
		<script src="<%=basePath%>/assets2/js/highcharts/modules/series-label.js"></script>
		<script src="<%=basePath%>/assets2/js/highcharts/modules/oldie.js"></script>
   		<script src="<%=path %>/assets2/js/bootstrap.min.js"></script>
    </head>
	<div class="row">
	<ol class="breadcrumb">
		<li><a href="<%=path%>/index"><span
				class="glyphicon glyphicon-home"></span></a></li>
		<li class="active">首页统计</li>
	</ol>
	</div>
   <div class="panel panel-default">
	<div class="panel-body">
		<div class="row">
			<div class="col-md-6">
				<div id="monthPurchaseLine"></div>
			</div>
			<div class="col-md-6">
				<div id="goodsPurchaseLine"></div>
			</div>
		</div>
		<div class="row">
			<div class="col-md-12">
				<div id="dayPurchaseLine"></div>
			</div>
		</div>
		<div class="row">
			<div class="col-md-12">
				<div id="merchantOfGoodsPageView"></div>
			</div>
		</div>
		<div class="row">
			<div class="col-md-12">
				<div id="daySalesMoneyLine"></div>
			</div>
		</div>
	</div>
   </div>
   <script type="text/javascript">
  $(function(){
	  //月销量
	  $.ajax({
	   	   url: "<%=path%>/web/monthPurchaseStatistical",
	       timeout: 300000,
	       dataType: "json",
	       type: "post",
	       success: function (data) {
	          var monthStr=new Array();
	          var monthCount=new Array();
	          for(var i=1;i<=12;i++){
	        	  monthStr[i]=i+"月";
	        	  monthCount[i-1]=0;
	        	  for(var x=0;x<data.length;x++){
	        		  var month=data[x].month.replace(/\b(0+)/gi,"")
	        		  if(i==month){
	        			  monthCount[i-1]=data[x].count;
	        		  }
	        	  }
	          }
	          Highcharts.chart('monthPurchaseLine', {
	        	chart: {
	        	    type: 'column'
	        	},
	      	    title: {
	      	        text: '月销量统计'
	      	    },
	      	  	xAxis: {
	              	categories: monthStr,
	              	labels: { 
                        rotation: 0, 
                        style: { 
                            fontSize: '13px', 
                            fontFamily: 'Verdana, sans-serif',
                            
                        }
                    }
	          	},
	      	    yAxis: {
	      	        title: {
	      	            text: ''
	      	        },
	      	    	type: 'logarithmic',
	              	minorTickInterval: 0.1
	      	    },
	      	    tooltip: {
	      	        headerFormat: '<b>销售量</b><br />',
	      	        pointFormat: '{point.x}月份销量：{point.y}'
	      	    },
	      	    series: [{
	      	    	name: '商品总销量',
	      	        data: monthCount,
	      	        pointStart: 1
	      	    }],
	      	    exporting: {
	      	    	enabled: false //隐藏导出图片  
	      	    },
	      	    credits: {
	      	    	enabled: false //隐藏highcharts的站点标志
	      	    },
	      	    legend: {                                                                    
	                enabled: false                                                           
	            }  
	      	});
	       }
	   });
	  //商品销量排行
	   $.ajax({
	   	   url: "<%=path%>/web/goodsPurchaseStatistical",
	       timeout: 300000,
	       dataType: "json",
	       type: "post",
	       success: function (data) {
	          var goodsStr=new Array();
	          var goodsCount=new Array();
	          for(var i=0;i<data.length;i++){
	        	  goodsStr[i]=data[i].goodsName;
	        	  goodsCount[i]=data[i].count;
	          }
	          Highcharts.chart('goodsPurchaseLine', {
	  		    chart: {
	  		        type: 'column',
	  		        inverted: true
	  		    },
	  		    title: {
	  		        text: '商品销量排行'
	  		    },
	  		    subtitle: {
	  		        style: {
	  		            position: 'absolute',
	  		            right: '0px',
	  		            bottom: '10px'
	  		        }
	  		    },
	  		    xAxis: {
	  		        categories: goodsStr
	  		    },
	  		    yAxis: {
	  		    	title: {
	  		            text: ''
	  		        },
	  		        allowDecimals: false,
	  		        min: 0
	  		    },
	  		    plotOptions: {
	  		        area: {
	  		            fillOpacity: 0.5
	  		        }
	  		    },
	  		    series: [{
	  		        name: '商品销量',
	  		        data: goodsCount
	  		    }],
	      	    exporting: {
	      	    	enabled: false //隐藏导出图片  
	      	    },
	      	    credits: {
	      	    	enabled: false //隐藏highcharts的站点标志
	      	    },
	      	    legend: {                                                                    
	                enabled: false                                                           
	            }  
	  		});
	       }
	   });
	   //日销量统计
	   $.ajax({
	   	   url: "<%=path%>/web/dayPurchaseStatistical",
	       timeout: 300000,
	       dataType: "json",
	       type: "post",
	       success: function (data) {
	          var dayStr=new Array();
	          var dayCount=new Array();
	          var date = new Date();
	          var day = new Date(date.getFullYear(),date.getMonth()+1,0);
	          var daycount = day.getDate();
	          for(var i=1;i<=daycount;i++){
	        	  dayStr[i]=i+"日";
	        	  dayCount[i-1]=0;
	        	  for(var x=0;x<data.length;x++){
	        		  var day=data[x].day.replace(/\b(0+)/gi,"")
	        		  if(i==day){
	        			  dayCount[i-1]=data[x].count;
	        		  }
	        	  }
	          }
	          Highcharts.chart('dayPurchaseLine', {
	        	chart: {
		        	type: 'column'
		       	},
	      	    title: {
	      	        text: '日销量统计'
	      	    },
	      	  	xAxis: {
	              	categories: dayStr
	          	},
	      	    yAxis: {
	      	        title: {
	      	            text: ''
	      	        },
	      	    	type: 'logarithmic',
	              	minorTickInterval: 0.1
	      	    },
	      	    tooltip: {
	      	        headerFormat: '<b>销售量</b><br />',
	      	        pointFormat: '{point.x}日销量：{point.y}'
	      	    },
	      	    series: [{
	      	    	name: '商品总销量',
	      	        data: dayCount,
	      	        pointStart: 1
	      	    }],
	      	    exporting: {
	      	    	enabled: false //隐藏导出图片  
	      	    },
	      	    credits: {
	      	    	enabled: false //隐藏highcharts的站点标志
	      	    },
	      	    legend: {                                                                    
	                  enabled: false                                                           
	              }  
	      	});
	       }
	   });
	   //店铺的商品浏览量
	   $.ajax({
	   	   url: "<%=path%>/web/getMerchantOfGoodsPageView",
	       timeout: 300000,
	       dataType: "json",
	       type: "post",
	       success: function (data) {
	          var goodsNameStr=new Array();
	          var pageViewCount=new Array();
	          for(var i=0;i<data.length;i++){
	        	  if(data[i].goodsName.length<10){
	        		  goodsNameStr[i+1]=data[i].goodsName;
	        	  }else{
	        		  goodsNameStr[i+1]=data[i].goodsName.substring(0,11)+"...";
	        	  }
	        	  pageViewCount[i]=data[i].pageView;
	        	  
	          }
	          Highcharts.chart('merchantOfGoodsPageView', {
		        	chart: {
			        	type: 'column'
			       	},
		      	    title: {
		      	        text: '商品浏览量'
		      	    },
		      	  	xAxis: {
		              	categories: goodsNameStr
		          	},
		      	    yAxis: {
		      	        title: {
		      	            text: ''
		      	        },
		      	    	type: 'logarithmic',
		              	minorTickInterval: 0.1
		      	    },
		      	    series: [{
		      	    	name: '商品浏览量',
		      	        data: pageViewCount,
		      	        pointStart: 1
		      	    }],
		      	    exporting: {
		      	    	enabled: false //隐藏导出图片  
		      	    },
		      	    credits: {
		      	    	enabled: false //隐藏highcharts的站点标志
		      	    },
		      	    legend: {                                                                    
		                  enabled: false                                                           
		              }  
		      	});
		       }
		   });
	  //每日店铺的销售金额
	   $.ajax({
	   	   url: "<%=path%>/web/getMerchantOfSalesMoney",
	       timeout: 300000,
	       dataType: "json",
	       type: "post",
	       success: function (data) {
	          var dayStr=new Array();
	          var dayCount=new Array();
	          var date = new Date();
	          var day = new Date(date.getFullYear(),date.getMonth()+1,0);
	          var daycount = day.getDate();
	          for(var i=1;i<=daycount;i++){
	        	  dayStr[i]=i+"日";
	        	  dayCount[i-1]=0;
	        	  for(var x=0;x<data.length;x++){
	        		  var day=data[x].DAY;
	        		  if(i==day){
	        			  dayCount[i-1]=data[x].SumGoodsPrice;
	        		  }
	        	  }
	          }
	          Highcharts.chart('daySalesMoneyLine', {
	        	chart: {
			        type: 'column'
			    },
	      	    title: {
	      	        text: '每日店铺的销售金额'
	      	    },
	      	  	xAxis: {
	              	categories: dayStr
	          	},
	      	    yAxis: {
	      	        title: {
	      	            text: ''
	      	        },
	      	    	type: 'logarithmic',
	              	minorTickInterval: 0.1
	      	    },
	      	    tooltip: {
	      	        headerFormat: '<b>销售总额</b><br />',
	      	        pointFormat: '{point.x}日销量总额：{point.y}'
	      	    },
	      	    series: [{
	      	    	name: '销售总额',
	      	        data: dayCount,
	      	        pointStart: 1
	      	    }],
	      	    exporting: {
	      	    	enabled: false //隐藏导出图片  
	      	    },
	      	    credits: {
	      	    	enabled: false //隐藏highcharts的站点标志
	      	    },
	      	    legend: {                                                                    
	                  enabled: false                                                           
	              }  
	      	});
	       }
	   });
	   
  })
   </script>
</html>